package com.puboot.module.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.puboot.common.util.Pagination;
import com.puboot.module.admin.mapper.BIzCoursePlanMapper;
import com.puboot.module.admin.model.BizCoursePlan;
import com.puboot.module.admin.service.BizCoursePlanService;
import com.puboot.module.admin.vo.CoursePlanConditionVo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @author ltc
 * @version 1.0
 * @date 2020/9/28 17:39
 */
@Service
@AllArgsConstructor
public class BizCoursePlanServiceImpl extends ServiceImpl<BIzCoursePlanMapper, BizCoursePlan> implements BizCoursePlanService {
    private final BIzCoursePlanMapper bIzCoursePlanMapper;
    @Override
    public List<BizCoursePlan> selectCoursePlans(BizCoursePlan bIzCoursePlan) {
        return bIzCoursePlanMapper.PageCoursePlans(null,bIzCoursePlan);
    }

    @Override
    public IPage<BizCoursePlan> PageCoursePlans(BizCoursePlan bIzCoursePlan, Integer pageNumber, Integer pageSize) {
        IPage<BizCoursePlan> page = new Pagination<>(pageNumber, pageSize);
        return page.setRecords(bIzCoursePlanMapper.PageCoursePlans(page, bIzCoursePlan));
    }

    /**
     * 分页查询
     *
     * @param page
     * @param vo
     * @return
     */
    @Override
    public List<BizCoursePlan> PageListCoursePlans(IPage<BizCoursePlan> page, CoursePlanConditionVo vo) {
        List<BizCoursePlan> bizCoursePlans = bIzCoursePlanMapper.PageListCoursePlans(page, vo);
        return bizCoursePlans;
    }

    @Override
    public List<BizCoursePlan> getByCourseId(Integer courseId) {
        return bIzCoursePlanMapper.getByCourseId(courseId);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        return bIzCoursePlanMapper.deleteBatchIds(Arrays.asList(ids));
    }
}
